﻿function queue(arr) {
    const result = [];
    for (let i = 0; i < arr.length; i++) {
        const ps = [];
        for (let j = 0; j < arr.length; j++) {
            const item = arr[j];
            if (i !== j) {
                ps.push(item);
            }
        }
        result.push(ps);
    }
    return result;
}
// const demo = queue(["02", "03", "04", "05", "08"]);
// console.table(demo);
// 日期批次 document.querySelectorAll("#tabtrend > tbody td:nth-child(1).line_r").forEach(e=>console.info(e.innerText))
// 1列 document.querySelectorAll("#tabtrend > tbody td:nth-child(2)").forEach(e=>console.info(e.innerText))
// 2列 document.querySelectorAll("#tabtrend > tbody td:nth-child(3)").forEach(e=>console.info(e.innerText))
// 3列 document.querySelectorAll("#tabtrend > tbody td:nth-child(4)").forEach(e=>console.info(e.innerText))
// 4列 document.querySelectorAll("#tabtrend > tbody td:nth-child(5)").forEach(e=>console.info(e.innerText))
// 5列 document.querySelectorAll("#tabtrend > tbody td:nth-child(6)").forEach(e=>console.info(e.innerText))
function parseData() {
    const titles = [];
    document
        .querySelectorAll("#tabtrend > tbody td:nth-child(1).line_r")
        .forEach(e => titles.push(e.innerText));
    //console.table(titles);
    const col0 = [];
    const col1 = [];
    const col2 = [];
    const col3 = [];
    const col4 = [];
    document
        .querySelectorAll("#tabtrend > tbody td:nth-child(2)")
        .forEach(e => col0.push(e.innerText));
    document
        .querySelectorAll("#tabtrend > tbody td:nth-child(3)")
        .forEach(e => col1.push(e.innerText));
    document
        .querySelectorAll("#tabtrend > tbody td:nth-child(4)")
        .forEach(e => col2.push(e.innerText));
    document
        .querySelectorAll("#tabtrend > tbody td:nth-child(5)")
        .forEach(e => col3.push(e.innerText));
    document
        .querySelectorAll("#tabtrend > tbody td:nth-child(6)")
        .forEach(e => col4.push(e.innerText));
    const tbl = [];
    for (let i = 0; i < titles.length; i++) {
        const t = titles[i];
        const c0 = col0[i];
        const c1 = col1[i];
        const c2 = col2[i];
        const c3 = col3[i];
        const c4 = col4[i];
        tbl.push([t, c0, c1, c2, c3, c4]);
    }
    // console.table(tbl);
    return tbl;
}
function find(arrData, arrTarget) {
    const result = [];
    const datas = arrData.map(m => m[1] + m[2] + m[3] + m[4] + m[5]);
    for (let j = 0; j < arrTarget.length; j++) {
        const target = arrTarget[j].join("");
        for (let i = 0; i < datas.length; i++) {
            const data = datas[i];
            if (data.indexOf(target) > 0) {
                result.push({
                    target: target,
                    data: data
                });
            }
        }
    }
    return result;
}
// find(parseData(),queue(['10','08','07','11','05']))
function find2(arrData, arrTarget) {
    const result = [];
    const datas = arrData.map(m => ({
        title: m[0],
        data: [m[1], m[2], m[3], m[4], m[5]]
    }));
    for (let i = 0; i < datas.length; i++) {
        const data = datas[i];
        let cnt = 0;
        for (let j = 0; j < arrTarget.length; j++) {
            const target = arrTarget[j];
            // console.info(data);
            // console.info(target);
            if (data.data.indexOf(target) >= 0) {
                cnt = cnt + 1;
                if (cnt === 4) {
                    result.push({
                        title: data.title,
                        data: data.data.join(',')
                    });
                }
            }
        }
    }
    return result;
}
